/**$Licence:
 *   Use this however/wherever you like, just don't blame me if it breaks anything.
 *   Copyright (C) 2008 - 2012 xingsheng.zhu@gmail.com All rights reserved.
 */
package com.blazemina.config;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author JackChu
 * @version 1.0.0 2012-2-8 上午10:10:11
 */
public class Protocols {
	/**
	 * 创建command的factory,默认使用java反射机制直接创建
	 */
	private String commandFactory = "com.blazemina.command.DefaultJavaCommandFactory";

	private Map<String, ActionConfig> commandConfigs = new ConcurrentHashMap<String, ActionConfig>();

	/**
	 * @return the commandConfigs
	 */
	public Map<String, ActionConfig> getCommandConfigs() {
		return commandConfigs;
	}

	/**
	 * @return the commandFactory
	 */
	public String getCommandFactory() {
		return commandFactory;
	}

	/**
	 * @param commandFactory
	 *            the commandFactory to set
	 */
	public void setCommandFactory(String commandFactory) {
		this.commandFactory = commandFactory;
	}

	public void addCommandConfig(ActionConfig config) {
		commandConfigs.put(config.getName(), config);
	}

	/**
	 * @return
	 */
	public int getCommandSize() {
		return commandConfigs.size();
	}
	
	public ActionConfig findCommandConfig(String commandName){
		return commandConfigs.get(commandName);
	}

}
